module Util.Enumerator where

import Data.Enumerator.Internal


until :: Monad m => (a -> Bool) -> Enumeratee a a m b
until pred = checkDone (continue . step) 
  where
	    step k EOF = yield (Continue k) EOF
	    step k (Chunks xs) = loop k xs

	    loop k [] = continue (step k)
	    loop k (x:xs)
	      | pred x    = yield (Continue k) EOF
	      | otherwise = do k (Chunks [x]) >>== checkDoneEx (Chunks xs) (`loop` xs)

